<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="/Public/Admin/css/pintuer.css">
    <link rel="stylesheet" href="/Public/Admin/css/admin.css">
    <script src="/Public/Admin/js/jquery.js"></script>
    <script src="/Public/Admin/js/pintuer.js"></script>
</head>
<body>



<div class="panel admin-panel">
    <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加内容</strong></div>
    <div class="body-content">
        <form name="main_form" class="form-x" id="myform" method="POST" action="/index.php/Admin/agent/add.html" enctype="multipart/form-data">
            <div class="form-group">
                <div class="label">
                    <label>代理名称：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" value="" name="agentname" data-validate="required:代理名称"/>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>密码：</label>
                </div>
                <div class="field">
                    <input type="password" class="input w50" value="" name="password" data-validate="required:代理密码"/>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>手机号：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" value="" onblur="isPoneAvailable(this.value)" name="phone"
                           data-validate="required:手机号"/>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>QQ号：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" value="" name="qq" data-validate="required:QQ号"/>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>微信号：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" value="" name="wx" data-validate="required:微信号"/>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>提现名称：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" value="" name="txname" data-validate="required:提现名称"/>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>所持金额：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" value="" name="money" data-validate="required:所持金额"/>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>提现费率：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" value="" name="txfl" data-validate="required:费率"/>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>请从以下域名中选择：</label>
                </div>
                <div class="">
                    <?php if(!empty($result)):?>
                    <select name="domain" class="input" style="width:200px; line-height:17px;">
                        <option value="">请选择域名</option>
                        <?php if(is_array($result)): foreach($result as $key=>$v): ?><option value="<?php echo $v['domainlink'];?>"><?php echo $v['domainlink'];?></option><?php endforeach; endif; ?>
                    </select>
                    <?php else:?>
                    <div class="label">
                        <label>暂无可用域名，请配置</label>
                    </div>
                    <?php endif;?>
                </div>
            </div>
           <!-- <div class="form-group">
                <div class="label">
                    <label>添加域名：</label>
                </div>
                <div class="field">
                <textarea class="input" name="domain"
                          style=" height:90px; width: 359.13px;"></textarea>
                    <div class="tips"><span style="color: red">请使用逗号进行分割</span></div>
                </div>
            </div>-->
            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <input id="submit" type="button" value="提交" class="button bg-blue">
                    <input type="reset" value="重置" class="button bg-red">
                    <input type="button" value="取消" onclick="javascript :history.back(-1)" class="button bg-blue">
                </div>
            </div>
        </form>
    </div>
</div>
<script src="/Public/layui/layui.all.js"></script>
<script>

    $("#submit").click(function () {
        var data = $("#myform").serialize();
        if ($("input[name='agentname']").val() == '' || $("input[name='agentname']").val() == undefined) {
            alert('代理名称不能为空');
            return false;
        }
        if ($("input[name='password']").val() == '' || $("input[name='password']").val() == undefined) {
            alert('密码不能为空');
            return false;
        }
        if ($("input[name='phone']").val() == '' || $("input[name='phone']").val() == undefined) {
            alert('手机号不能为空');
            return false;
        }
        if ($("input[name='txname']").val() == '' || $("input[name='txname']").val() == undefined) {
            alert('提现人名称不能为空');
            return false;
        }
        if ($("select").val() == '' || $("select").val() == undefined) {
            alert('域名不能为空');
            return false;
        }
        $.post("<?php echo U('add')?>", data, function (res) {
            alert(res.info);
            location.href = res.url;
        })
    })

    function isPoneAvailable(poneInput) {

        var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
        if (!myreg.test(poneInput)) {
            alert('手机号码不正确！');
            return false;
        }
    }


    //判断用户名是否存在
    $(function () {
        $("input[name='agentname']").blur(function () {
            $.post('<?php echo U(checkname)?>', {data: $(this).val()}, function (res) {
                if (res == 1) {
                    alert('用户名已存在！，请重新输入');
                    return false;
                }
            });
        });

    });

</script>

</body>
</html>